package view;

import controller.SetterController;
import controller.StudentController;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import javax.swing.*;


/**
 *
 * @author FELIPE & NICOLAS
 */
public class SetterGUI extends javax.swing.JFrame {


    SetterController controller;
    DefaultListModel modelList;     
    DefaultListModel modelListFIBQ;
    DefaultComboBoxModel modelComboBox;
    
    boolean newQuestion = false;        //flag variable to identify if the information given is for editing the actual question or for adding a new one
    boolean newSubSection = false;      //flag variable to identify if the information given is for editing the actual SubSection or for adding a new one
    boolean newSection = false;         //flag variable to identify if the information given is for editing the actual Section or for adding a new one
    
    int blankCounter=0;
    
    //variables for icons
    final URL urlStop = getClass().getResource("/images/stop64.png");
    final URL urlDone = getClass().getResource("/images/done64.png");
    final URL urlQuestion = getClass().getResource("/images/question64.png");

    //constructor
    public SetterGUI() {
        
        initComponents();               //add all the swing components and edit there properties
        
        //do not allow the user to close this components to prevent errors drign process
        this.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        this.dlgAddEditQuestion.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        this.dlgAddEditSection.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        this.dlgAddEditSubSection.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        this.dlgEditTest.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        this.dlgTestDetails.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        
        //set all the elements to appear on the center of scree
        this.setLocationRelativeTo(null);                           //center of screen
        this.dlgAddEditQuestion.setLocationRelativeTo(null);        //center of screen
        this.dlgAddEditSection.setLocationRelativeTo(null);         //center of screen
        this.dlgAddEditSubSection.setLocationRelativeTo(null);      //center of screen
        this.dlgEditTest.setLocationRelativeTo(null);               //center of screen
        this.dlgTestDetails.setLocationRelativeTo(null);            //center of screen
        
        controller = new SetterController(this);                    //instantiate the controller asigned to this GUI class
        modelList = new DefaultListModel();
        modelListFIBQ = new DefaultListModel();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dlgTestDetails = new javax.swing.JDialog();
        jPanel5 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        txtTestName = new javax.swing.JTextField();
        txtAuthor = new javax.swing.JTextField();
        txtDescription = new javax.swing.JTextField();
        btnCreate = new javax.swing.JButton();
        btnCancel = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        dlgAddEditQuestion = new javax.swing.JDialog();
        btnCancelAdd = new javax.swing.JButton();
        btnSaveQuestion = new javax.swing.JButton();
        lblMode = new javax.swing.JLabel();
        jPanel10 = new javax.swing.JPanel();
        tabAddEditQuestion = new javax.swing.JTabbedPane();
        jPanel4 = new javax.swing.JPanel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        lstPossAnswers = new javax.swing.JList();
        jLabel15 = new javax.swing.JLabel();
        btnSelectImageMCQ = new javax.swing.JButton();
        btnDeletePoss = new javax.swing.JButton();
        txtQuestion = new javax.swing.JTextField();
        txtMarks = new javax.swing.JTextField();
        txtPossAnswer = new javax.swing.JTextField();
        jLabel20 = new javax.swing.JLabel();
        cmbCorrectAnswer = new javax.swing.JComboBox();
        jLabel14 = new javax.swing.JLabel();
        txtPenalty = new javax.swing.JTextField();
        jLabel36 = new javax.swing.JLabel();
        chbAuto = new javax.swing.JCheckBox();
        jLabel39 = new javax.swing.JLabel();
        btnAddPoss1 = new javax.swing.JButton();
        lblImageMCQ = new javax.swing.JLabel();
        btnRemoveImageMCQ = new javax.swing.JButton();
        jPanel11 = new javax.swing.JPanel();
        jLabel34 = new javax.swing.JLabel();
        txtMarksFIB = new javax.swing.JTextField();
        jLabel35 = new javax.swing.JLabel();
        txtCorrAnswerFIB = new javax.swing.JTextField();
        jScrollPane3 = new javax.swing.JScrollPane();
        lstCorrFIB = new javax.swing.JList();
        btnAddCorrFIB = new javax.swing.JButton();
        btnDeleteCorrFIB = new javax.swing.JButton();
        jPanel6 = new javax.swing.JPanel();
        chbMultipleBlanks = new javax.swing.JCheckBox();
        btnClearQuestion = new javax.swing.JButton();
        btnAddBlank = new javax.swing.JButton();
        btnAddText = new javax.swing.JButton();
        jLabel33 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        pnlQuestion = new javax.swing.JPanel();
        txtPenaltyFIB = new javax.swing.JTextField();
        jLabel37 = new javax.swing.JLabel();
        jLabel38 = new javax.swing.JLabel();
        jLabel40 = new javax.swing.JLabel();
        lblImageBLANK = new javax.swing.JLabel();
        btnSelectImageBLANK = new javax.swing.JButton();
        btnRemoveImageBLANK = new javax.swing.JButton();
        dlgAddEditSubSection = new javax.swing.JDialog();
        lblModeSubSection = new javax.swing.JLabel();
        jPanel8 = new javax.swing.JPanel();
        jLabel24 = new javax.swing.JLabel();
        btnSaveSubSection = new javax.swing.JButton();
        btnCancelSubSection = new javax.swing.JButton();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        txtSubSectionName = new javax.swing.JTextField();
        txtSubSectionDescription = new javax.swing.JTextField();
        jLabel31 = new javax.swing.JLabel();
        dlgAddEditSection = new javax.swing.JDialog();
        lblModeSection = new javax.swing.JLabel();
        jPanel9 = new javax.swing.JPanel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        txtSectionName = new javax.swing.JTextField();
        txtSectionDescription = new javax.swing.JTextField();
        btnCancelSection = new javax.swing.JButton();
        btnSaveSection = new javax.swing.JButton();
        jLabel21 = new javax.swing.JLabel();
        txtSectionTime = new javax.swing.JTextField();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jLabel32 = new javax.swing.JLabel();
        dlgEditTest = new javax.swing.JDialog();
        jPanel7 = new javax.swing.JPanel();
        txtEditTestDesc = new javax.swing.JTextField();
        jLabel27 = new javax.swing.JLabel();
        jLabel28 = new javax.swing.JLabel();
        btnCancelEditTest = new javax.swing.JButton();
        btnConfirmEditTest = new javax.swing.JButton();
        jLabel23 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        txtEditTestName = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        txtEditAuthor = new javax.swing.JTextField();
        btnSelectImageMCQ1 = new javax.swing.JButton();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel41 = new javax.swing.JLabel();
        jToolBar1 = new javax.swing.JToolBar();
        btnNewTest = new javax.swing.JButton();
        btnOpenTest = new javax.swing.JButton();
        btnSaveTest = new javax.swing.JButton();
        btnExploreImageGallery = new javax.swing.JButton();
        btnLogOut = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        jLabel9 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        lblTestName = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        lblAuthor = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        btnEditTest = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        cmbSections = new javax.swing.JComboBox();
        btnEditSection = new javax.swing.JButton();
        btnDeleteSection = new javax.swing.JButton();
        btnAddSection = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        cmbSubSections = new javax.swing.JComboBox();
        btnEditSubSection = new javax.swing.JButton();
        btnDeleteSubSection = new javax.swing.JButton();
        btnAddSubSection = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        lstQuestions = new javax.swing.JList();
        btnEditQuestion = new javax.swing.JButton();
        btnDeleteQuestion = new javax.swing.JButton();
        btnAddQuestion = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        lblSection = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        lblSubSection = new javax.swing.JLabel();
        btnTakeTest = new javax.swing.JButton();

        dlgTestDetails.setBounds(new java.awt.Rectangle(0, 22, 400, 380));
        dlgTestDetails.getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jLabel2.setText("Test name:");

        jLabel4.setText("Author name:");

        jLabel6.setText("Description:");

        btnCreate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/new24.png"))); // NOI18N
        btnCreate.setText("Create");
        btnCreate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCreateActionPerformed(evt);
            }
        });

        btnCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Cancel24.png"))); // NOI18N
        btnCancel.setText("Cancel");
        btnCancel.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelActionPerformed(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("Lucida Grande", 1, 14)); // NOI18N
        jLabel10.setText("New test information");

        jLabel30.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/info48.png"))); // NOI18N

        org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(btnCancel)
                .add(18, 18, 18)
                .add(btnCreate)
                .add(13, 13, 13))
            .add(jPanel5Layout.createSequentialGroup()
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel5Layout.createSequentialGroup()
                        .add(84, 84, 84)
                        .add(jLabel10))
                    .add(jPanel5Layout.createSequentialGroup()
                        .add(16, 16, 16)
                        .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(jPanel5Layout.createSequentialGroup()
                                .add(jLabel6)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(txtDescription, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 200, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                            .add(jPanel5Layout.createSequentialGroup()
                                .add(jLabel4)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(txtAuthor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 199, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                            .add(jPanel5Layout.createSequentialGroup()
                                .add(jLabel2)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(txtTestName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 200, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                    .add(jPanel5Layout.createSequentialGroup()
                        .add(139, 139, 139)
                        .add(jLabel30)))
                .addContainerGap(22, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel5Layout.createSequentialGroup()
                .add(15, 15, 15)
                .add(jLabel30)
                .add(18, 18, 18)
                .add(jLabel10)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(txtTestName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel2))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel4)
                    .add(txtAuthor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(8, 8, 8)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(txtDescription, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel6))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 26, Short.MAX_VALUE)
                .add(jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(btnCancel)
                    .add(btnCreate))
                .add(18, 18, 18))
        );

        dlgTestDetails.getContentPane().add(jPanel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 20, 340, 300));

        dlgAddEditQuestion.setBounds(new java.awt.Rectangle(0, 22, 800, 650));

        btnCancelAdd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Cancel24.png"))); // NOI18N
        btnCancelAdd.setText("Cancel");
        btnCancelAdd.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelAddActionPerformed(evt);
            }
        });

        btnSaveQuestion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Save24.png"))); // NOI18N
        btnSaveQuestion.setText("Save Question");
        btnSaveQuestion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveQuestionActionPerformed(evt);
            }
        });

        lblMode.setFont(new java.awt.Font("Lucida Grande", 2, 16)); // NOI18N
        lblMode.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/warning24.png"))); // NOI18N

        jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jLabel12.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N
        jLabel12.setText("Question:");

        jLabel13.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N
        jLabel13.setText("Marks:");

        jScrollPane2.setViewportView(lstPossAnswers);

        jLabel15.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N
        jLabel15.setText("Possible Answer:");

        btnSelectImageMCQ.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/image16.png"))); // NOI18N
        btnSelectImageMCQ.setText("Select Image");
        btnSelectImageMCQ.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        btnSelectImageMCQ.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
        btnSelectImageMCQ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSelectImageMCQActionPerformed(evt);
            }
        });

        btnDeletePoss.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/delete16.png"))); // NOI18N
        btnDeletePoss.setText("Delete Possible Answer <--");
        btnDeletePoss.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeletePossActionPerformed(evt);
            }
        });

        txtMarks.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtMarksActionPerformed(evt);
            }
        });
        txtMarks.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                txtMarksFocusLost(evt);
            }
        });

        jLabel20.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N
        jLabel20.setText("List of Possible Answer:");

        jLabel14.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N
        jLabel14.setText("Correct Answer:");

        txtPenalty.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtPenaltyActionPerformed(evt);
            }
        });

        jLabel36.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N
        jLabel36.setText("Penalty:");

        chbAuto.setText("Auto");
        chbAuto.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                chbAutoItemStateChanged(evt);
            }
        });
        chbAuto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chbAutoActionPerformed(evt);
            }
        });

        jLabel39.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N
        jLabel39.setText("Image (optional):");

        btnAddPoss1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/add16.png"))); // NOI18N
        btnAddPoss1.setText("  Add Possible Answer-->");
        btnAddPoss1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddPoss1ActionPerformed(evt);
            }
        });

        lblImageMCQ.setFont(new java.awt.Font("Lucida Grande", 2, 13)); // NOI18N
        lblImageMCQ.setText("No image");

        btnRemoveImageMCQ.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/delete16.png"))); // NOI18N
        btnRemoveImageMCQ.setText("Remove");
        btnRemoveImageMCQ.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        btnRemoveImageMCQ.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
        btnRemoveImageMCQ.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRemoveImageMCQActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel4Layout = new org.jdesktop.layout.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jPanel4Layout.createSequentialGroup()
                            .add(jLabel12)
                            .add(12, 12, 12)
                            .add(txtQuestion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 490, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(jPanel4Layout.createSequentialGroup()
                            .add(19, 19, 19)
                            .add(jLabel13)
                            .add(12, 12, 12)
                            .add(txtMarks, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 77, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(18, 18, 18)
                            .add(jLabel36)
                            .add(12, 12, 12)
                            .add(txtPenalty, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 77, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(6, 6, 6)
                            .add(chbAuto)))
                    .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jPanel4Layout.createSequentialGroup()
                            .add(427, 427, 427)
                            .add(jLabel20))
                        .add(jPanel4Layout.createSequentialGroup()
                            .add(17, 17, 17)
                            .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                .add(jLabel14)
                                .add(jLabel15)
                                .add(jLabel39))
                            .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                .add(jPanel4Layout.createSequentialGroup()
                                    .add(66, 66, 66)
                                    .add(btnDeletePoss, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 190, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel4Layout.createSequentialGroup()
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                        .add(org.jdesktop.layout.GroupLayout.TRAILING, cmbCorrectAnswer, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 250, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(org.jdesktop.layout.GroupLayout.TRAILING, btnAddPoss1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 190, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                                .add(jPanel4Layout.createSequentialGroup()
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                        .add(jPanel4Layout.createSequentialGroup()
                                            .add(btnSelectImageMCQ)
                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                            .add(btnRemoveImageMCQ))
                                        .add(txtPossAnswer, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 250, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                                .add(jPanel4Layout.createSequentialGroup()
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                    .add(lblImageMCQ, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                            .add(6, 6, 6)
                            .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 234, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                .add(43, 43, 43))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel4Layout.createSequentialGroup()
                .add(48, 48, 48)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel4Layout.createSequentialGroup()
                        .add(6, 6, 6)
                        .add(jLabel12))
                    .add(txtQuestion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel4Layout.createSequentialGroup()
                        .add(6, 6, 6)
                        .add(jLabel13))
                    .add(txtMarks, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jPanel4Layout.createSequentialGroup()
                        .add(6, 6, 6)
                        .add(jLabel36))
                    .add(txtPenalty, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jPanel4Layout.createSequentialGroup()
                        .add(2, 2, 2)
                        .add(chbAuto)))
                .add(32, 32, 32)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel39)
                    .add(lblImageMCQ))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(btnSelectImageMCQ)
                    .add(btnRemoveImageMCQ))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 26, Short.MAX_VALUE)
                .add(jLabel20)
                .add(6, 6, 6)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel4Layout.createSequentialGroup()
                        .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(txtPossAnswer, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel15))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(btnAddPoss1)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(btnDeletePoss))
                    .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 172, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(15, 15, 15)
                .add(jPanel4Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(cmbCorrectAnswer, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel14))
                .add(32, 32, 32))
        );

        tabAddEditQuestion.addTab("MULTIPLE CHOICE", jPanel4);

        jLabel34.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N
        jLabel34.setText("Marks:");

        jLabel35.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N
        jLabel35.setText("Correct Answer:");

        jScrollPane3.setViewportView(lstCorrFIB);

        btnAddCorrFIB.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/add16.png"))); // NOI18N
        btnAddCorrFIB.setText("Add Correct Answer  -->");
        btnAddCorrFIB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddCorrFIBActionPerformed(evt);
            }
        });

        btnDeleteCorrFIB.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/delete16.png"))); // NOI18N
        btnDeleteCorrFIB.setText("Delete Correct Answer <--");
        btnDeleteCorrFIB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteCorrFIBActionPerformed(evt);
            }
        });

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        chbMultipleBlanks.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N
        chbMultipleBlanks.setText("Allow multiples blanks");
        chbMultipleBlanks.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                chbMultipleBlanksItemStateChanged(evt);
            }
        });
        chbMultipleBlanks.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                chbMultipleBlanksActionPerformed(evt);
            }
        });

        btnClearQuestion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/clear16.png"))); // NOI18N
        btnClearQuestion.setText("Clear");
        btnClearQuestion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnClearQuestionActionPerformed(evt);
            }
        });

        btnAddBlank.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/add2_16.png"))); // NOI18N
        btnAddBlank.setText("Add Blank");
        btnAddBlank.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddBlankActionPerformed(evt);
            }
        });

        btnAddText.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/add2_16.png"))); // NOI18N
        btnAddText.setText("Add Text");
        btnAddText.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddTextActionPerformed(evt);
            }
        });

        jLabel33.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N
        jLabel33.setText("Question:");

        pnlQuestion.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
        jScrollPane4.setViewportView(pnlQuestion);

        org.jdesktop.layout.GroupLayout jPanel6Layout = new org.jdesktop.layout.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPane4)
                    .add(jPanel6Layout.createSequentialGroup()
                        .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jLabel33)
                            .add(jPanel6Layout.createSequentialGroup()
                                .add(btnAddText)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                .add(btnAddBlank)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(btnClearQuestion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 93, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                            .add(chbMultipleBlanks))
                        .add(0, 277, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .add(chbMultipleBlanks)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel6Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(btnAddText)
                    .add(btnAddBlank)
                    .add(btnClearQuestion))
                .add(18, 18, 18)
                .add(jLabel33)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane4, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 75, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel37.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N
        jLabel37.setText("Penalty:");

        jLabel38.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N
        jLabel38.setText("List of Possible Correct Answers:");

        jLabel40.setFont(new java.awt.Font("Lucida Grande", 1, 13)); // NOI18N
        jLabel40.setText("Image (optional):");

        lblImageBLANK.setFont(new java.awt.Font("Lucida Grande", 2, 13)); // NOI18N
        lblImageBLANK.setText("No image");

        btnSelectImageBLANK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/image16.png"))); // NOI18N
        btnSelectImageBLANK.setText("Select Image");
        btnSelectImageBLANK.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        btnSelectImageBLANK.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
        btnSelectImageBLANK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSelectImageBLANKActionPerformed(evt);
            }
        });

        btnRemoveImageBLANK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/delete16.png"))); // NOI18N
        btnRemoveImageBLANK.setText("Remove");
        btnRemoveImageBLANK.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        btnRemoveImageBLANK.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
        btnRemoveImageBLANK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRemoveImageBLANKActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel11Layout = new org.jdesktop.layout.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel11Layout.createSequentialGroup()
                .add(jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel11Layout.createSequentialGroup()
                        .add(33, 33, 33)
                        .add(jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jPanel11Layout.createSequentialGroup()
                                .add(114, 114, 114)
                                .add(btnSelectImageBLANK)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(btnRemoveImageBLANK))
                            .add(jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                .add(jPanel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(jPanel11Layout.createSequentialGroup()
                                    .add(jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                        .add(jPanel11Layout.createSequentialGroup()
                                            .add(jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                                .add(jLabel35)
                                                .add(jLabel34))
                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                            .add(jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                                .add(jPanel11Layout.createSequentialGroup()
                                                    .add(txtMarksFIB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 58, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                    .add(jLabel37)
                                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                    .add(txtPenaltyFIB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 58, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                                .add(txtCorrAnswerFIB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 204, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                                        .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel11Layout.createSequentialGroup()
                                            .add(6, 6, 6)
                                            .add(jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                                .add(btnAddCorrFIB, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                                .add(btnDeleteCorrFIB, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                                    .add(jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                        .add(jPanel11Layout.createSequentialGroup()
                                            .add(26, 26, 26)
                                            .add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                                        .add(jPanel11Layout.createSequentialGroup()
                                            .add(38, 38, 38)
                                            .add(jLabel38)
                                            .add(0, 0, Short.MAX_VALUE)))))))
                    .add(jPanel11Layout.createSequentialGroup()
                        .add(24, 24, 24)
                        .add(jLabel40)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(lblImageBLANK, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 186, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(59, Short.MAX_VALUE))
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel11Layout.createSequentialGroup()
                .addContainerGap(32, Short.MAX_VALUE)
                .add(jPanel6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel40)
                    .add(lblImageBLANK))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(btnSelectImageBLANK)
                    .add(btnRemoveImageBLANK))
                .add(29, 29, 29)
                .add(jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel11Layout.createSequentialGroup()
                        .add(jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                .add(txtPenaltyFIB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(jLabel37))
                            .add(jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                                .add(txtMarksFIB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(jLabel34)))
                        .add(20, 20, 20))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel11Layout.createSequentialGroup()
                        .add(jLabel38)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)))
                .add(jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel11Layout.createSequentialGroup()
                        .add(jPanel11Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(txtCorrAnswerFIB, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(jLabel35))
                        .add(18, 18, 18)
                        .add(btnAddCorrFIB)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(btnDeleteCorrFIB))
                    .add(jScrollPane3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 116, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(17, 17, 17))
        );

        tabAddEditQuestion.addTab("FILL IN THE BLANK", jPanel11);

        org.jdesktop.layout.GroupLayout jPanel10Layout = new org.jdesktop.layout.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .add(tabAddEditQuestion))
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel10Layout.createSequentialGroup()
                .addContainerGap()
                .add(tabAddEditQuestion)
                .addContainerGap())
        );

        org.jdesktop.layout.GroupLayout dlgAddEditQuestionLayout = new org.jdesktop.layout.GroupLayout(dlgAddEditQuestion.getContentPane());
        dlgAddEditQuestion.getContentPane().setLayout(dlgAddEditQuestionLayout);
        dlgAddEditQuestionLayout.setHorizontalGroup(
            dlgAddEditQuestionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(dlgAddEditQuestionLayout.createSequentialGroup()
                .add(dlgAddEditQuestionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                    .add(dlgAddEditQuestionLayout.createSequentialGroup()
                        .addContainerGap()
                        .add(lblMode, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 446, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(btnCancelAdd, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 126, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(btnSaveQuestion))
                    .add(dlgAddEditQuestionLayout.createSequentialGroup()
                        .add(15, 15, 15)
                        .add(jPanel10, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(50, Short.MAX_VALUE))
        );
        dlgAddEditQuestionLayout.setVerticalGroup(
            dlgAddEditQuestionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(dlgAddEditQuestionLayout.createSequentialGroup()
                .add(17, 17, 17)
                .add(jPanel10, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(18, 18, 18)
                .add(dlgAddEditQuestionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(dlgAddEditQuestionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(btnCancelAdd)
                        .add(btnSaveQuestion))
                    .add(lblMode))
                .add(14, 14, 14))
        );

        dlgAddEditSubSection.setBounds(new java.awt.Rectangle(0, 22, 500, 420));

        lblModeSubSection.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/warning24.png"))); // NOI18N

        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jLabel24.setFont(new java.awt.Font("Lucida Grande", 0, 18)); // NOI18N
        jLabel24.setText("SubSection Information");

        btnSaveSubSection.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Save24.png"))); // NOI18N
        btnSaveSubSection.setText("Save SubSection");
        btnSaveSubSection.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveSubSectionActionPerformed(evt);
            }
        });

        btnCancelSubSection.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Cancel24.png"))); // NOI18N
        btnCancelSubSection.setText("Cancel");
        btnCancelSubSection.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelSubSectionActionPerformed(evt);
            }
        });

        jLabel16.setText("Sub Section Name:");

        jLabel17.setText("Description:");

        jLabel31.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/info48.png"))); // NOI18N

        org.jdesktop.layout.GroupLayout jPanel8Layout = new org.jdesktop.layout.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel8Layout.createSequentialGroup()
                .add(jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel8Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(jPanel8Layout.createSequentialGroup()
                                .add(jLabel16)
                                .add(6, 6, 6)
                                .add(txtSubSectionName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 237, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                            .add(jPanel8Layout.createSequentialGroup()
                                .add(20, 20, 20)
                                .add(jLabel17)
                                .add(26, 26, 26)
                                .add(jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jPanel8Layout.createSequentialGroup()
                                        .add(btnCancelSubSection)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                                        .add(btnSaveSubSection))
                                    .add(txtSubSectionDescription, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 237, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))))
                    .add(jPanel8Layout.createSequentialGroup()
                        .add(78, 78, 78)
                        .add(jLabel24))
                    .add(jPanel8Layout.createSequentialGroup()
                        .add(155, 155, 155)
                        .add(jLabel31)))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel8Layout.createSequentialGroup()
                .addContainerGap(17, Short.MAX_VALUE)
                .add(jLabel31)
                .add(18, 18, 18)
                .add(jLabel24)
                .add(33, 33, 33)
                .add(jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel8Layout.createSequentialGroup()
                        .add(6, 6, 6)
                        .add(jLabel16))
                    .add(txtSubSectionName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel8Layout.createSequentialGroup()
                        .add(6, 6, 6)
                        .add(jLabel17))
                    .add(txtSubSectionDescription, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(jPanel8Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(btnCancelSubSection)
                    .add(btnSaveSubSection))
                .add(18, 18, 18))
        );

        org.jdesktop.layout.GroupLayout dlgAddEditSubSectionLayout = new org.jdesktop.layout.GroupLayout(dlgAddEditSubSection.getContentPane());
        dlgAddEditSubSection.getContentPane().setLayout(dlgAddEditSubSectionLayout);
        dlgAddEditSubSectionLayout.setHorizontalGroup(
            dlgAddEditSubSectionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(dlgAddEditSubSectionLayout.createSequentialGroup()
                .add(dlgAddEditSubSectionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(dlgAddEditSubSectionLayout.createSequentialGroup()
                        .add(37, 37, 37)
                        .add(jPanel8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(dlgAddEditSubSectionLayout.createSequentialGroup()
                        .add(72, 72, 72)
                        .add(lblModeSubSection)))
                .addContainerGap(47, Short.MAX_VALUE))
        );
        dlgAddEditSubSectionLayout.setVerticalGroup(
            dlgAddEditSubSectionLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(dlgAddEditSubSectionLayout.createSequentialGroup()
                .add(24, 24, 24)
                .add(jPanel8, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(lblModeSubSection)
                .addContainerGap(44, Short.MAX_VALUE))
        );

        dlgAddEditSection.setBounds(new java.awt.Rectangle(0, 22, 470, 500));
        dlgAddEditSection.getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        lblModeSection.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/warning24.png"))); // NOI18N
        dlgAddEditSection.getContentPane().add(lblModeSection, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 420, -1, -1));

        jPanel9.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jLabel18.setText("Section Name:");

        jLabel19.setText("Description:");

        btnCancelSection.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Cancel24.png"))); // NOI18N
        btnCancelSection.setText("Cancel");
        btnCancelSection.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelSectionActionPerformed(evt);
            }
        });

        btnSaveSection.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Save24.png"))); // NOI18N
        btnSaveSection.setText("Save Section");
        btnSaveSection.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveSectionActionPerformed(evt);
            }
        });

        jLabel21.setText("Time Limit (min):");

        jLabel25.setFont(new java.awt.Font("Lucida Grande", 0, 18)); // NOI18N
        jLabel25.setText("Section Information");

        jLabel26.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/clock24.png"))); // NOI18N

        jLabel32.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/info48.png"))); // NOI18N

        org.jdesktop.layout.GroupLayout jPanel9Layout = new org.jdesktop.layout.GroupLayout(jPanel9);
        jPanel9.setLayout(jPanel9Layout);
        jPanel9Layout.setHorizontalGroup(
            jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel9Layout.createSequentialGroup()
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel9Layout.createSequentialGroup()
                        .add(0, 0, Short.MAX_VALUE)
                        .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(jPanel9Layout.createSequentialGroup()
                                .add(jLabel21)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(txtSectionTime, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 43, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(76, 76, 76))
                            .add(jPanel9Layout.createSequentialGroup()
                                .add(btnCancelSection)
                                .add(18, 18, 18)))
                        .add(btnSaveSection)
                        .add(44, 44, 44))
                    .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel9Layout.createSequentialGroup()
                            .add(jLabel19)
                            .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                .add(jPanel9Layout.createSequentialGroup()
                                    .add(79, 79, 79)
                                    .add(jLabel26)
                                    .add(199, 199, 199))
                                .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel9Layout.createSequentialGroup()
                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                    .add(txtSectionDescription, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 208, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(58, 58, 58))))
                        .add(jPanel9Layout.createSequentialGroup()
                            .add(jLabel18)
                            .add(23, 23, 23)
                            .add(txtSectionName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 208, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .addContainerGap()))))
            .add(jPanel9Layout.createSequentialGroup()
                .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel9Layout.createSequentialGroup()
                        .add(152, 152, 152)
                        .add(jLabel32))
                    .add(jPanel9Layout.createSequentialGroup()
                        .add(96, 96, 96)
                        .add(jLabel25)))
                .add(0, 0, Short.MAX_VALUE))
        );
        jPanel9Layout.setVerticalGroup(
            jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel9Layout.createSequentialGroup()
                .add(23, 23, 23)
                .add(jLabel32)
                .add(18, 18, 18)
                .add(jLabel25)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 40, Short.MAX_VALUE)
                .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel18)
                    .add(txtSectionName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel19)
                    .add(txtSectionDescription, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(14, 14, 14)
                .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jLabel21)
                        .add(txtSectionTime, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jLabel26))
                .add(47, 47, 47)
                .add(jPanel9Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(btnCancelSection)
                    .add(btnSaveSection))
                .add(18, 18, 18))
        );

        dlgAddEditSection.getContentPane().add(jPanel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 20, 390, 380));

        dlgEditTest.setBounds(new java.awt.Rectangle(0, 22, 420, 440));

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jLabel27.setFont(new java.awt.Font("Lucida Grande", 0, 18)); // NOI18N
        jLabel27.setText("Test Information");

        jLabel28.setText("Description");

        btnCancelEditTest.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Cancel24.png"))); // NOI18N
        btnCancelEditTest.setText("Cancel");
        btnCancelEditTest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelEditTestActionPerformed(evt);
            }
        });

        btnConfirmEditTest.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Save24.png"))); // NOI18N
        btnConfirmEditTest.setText("Save Changes");
        btnConfirmEditTest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnConfirmEditTestActionPerformed(evt);
            }
        });

        jLabel23.setText("Author:");

        jLabel29.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/info48.png"))); // NOI18N

        jLabel22.setText("Test Name:");

        org.jdesktop.layout.GroupLayout jPanel7Layout = new org.jdesktop.layout.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel7Layout.createSequentialGroup()
                .add(36, 36, 36)
                .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                        .add(jPanel7Layout.createSequentialGroup()
                            .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                .add(jLabel22)
                                .add(jLabel23))
                            .add(18, 18, 18)
                            .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                .add(txtEditTestName)
                                .add(txtEditAuthor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 161, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                        .add(jPanel7Layout.createSequentialGroup()
                            .add(jLabel28)
                            .add(18, 18, 18)
                            .add(txtEditTestDesc, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 161, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(jPanel7Layout.createSequentialGroup()
                            .add(btnCancelEditTest)
                            .add(18, 18, 18)
                            .add(btnConfirmEditTest)))
                    .add(jPanel7Layout.createSequentialGroup()
                        .add(61, 61, 61)
                        .add(jLabel27))
                    .add(jPanel7Layout.createSequentialGroup()
                        .add(111, 111, 111)
                        .add(jLabel29)))
                .addContainerGap(39, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel7Layout.createSequentialGroup()
                .add(18, 18, 18)
                .add(jLabel29)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jLabel27)
                .add(34, 34, 34)
                .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel22)
                    .add(txtEditTestName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel23)
                    .add(txtEditAuthor, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(18, 18, 18)
                .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel28)
                    .add(txtEditTestDesc, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(35, 35, 35)
                .add(jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(btnCancelEditTest)
                    .add(btnConfirmEditTest))
                .addContainerGap(30, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout dlgEditTestLayout = new org.jdesktop.layout.GroupLayout(dlgEditTest.getContentPane());
        dlgEditTest.getContentPane().setLayout(dlgEditTestLayout);
        dlgEditTestLayout.setHorizontalGroup(
            dlgEditTestLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(dlgEditTestLayout.createSequentialGroup()
                .add(31, 31, 31)
                .add(jPanel7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(29, Short.MAX_VALUE))
        );
        dlgEditTestLayout.setVerticalGroup(
            dlgEditTestLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(dlgEditTestLayout.createSequentialGroup()
                .add(19, 19, 19)
                .add(jPanel7, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(43, Short.MAX_VALUE))
        );

        btnSelectImageMCQ1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/image16.png"))); // NOI18N
        btnSelectImageMCQ1.setText("Select Image");
        btnSelectImageMCQ1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        btnSelectImageMCQ1.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
        btnSelectImageMCQ1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSelectImageMCQ1ActionPerformed(evt);
            }
        });

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));

        jLabel41.setText("jLabel41");

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jToolBar1.setRollover(true);

        btnNewTest.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/New 64.png"))); // NOI18N
        btnNewTest.setToolTipText("New Test");
        btnNewTest.setFocusable(false);
        btnNewTest.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnNewTest.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnNewTest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnNewTestActionPerformed(evt);
            }
        });
        jToolBar1.add(btnNewTest);

        btnOpenTest.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Open 64.png"))); // NOI18N
        btnOpenTest.setToolTipText("Open Test");
        btnOpenTest.setFocusable(false);
        btnOpenTest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOpenTestActionPerformed(evt);
            }
        });
        jToolBar1.add(btnOpenTest);

        btnSaveTest.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Disk 64.png"))); // NOI18N
        btnSaveTest.setToolTipText("Save Test");
        btnSaveTest.setFocusable(false);
        btnSaveTest.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnSaveTest.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnSaveTest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnSaveTestActionPerformed(evt);
            }
        });
        jToolBar1.add(btnSaveTest);

        btnExploreImageGallery.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/images64.png"))); // NOI18N
        btnExploreImageGallery.setToolTipText("Explore Image Gallery");
        btnExploreImageGallery.setFocusable(false);
        btnExploreImageGallery.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnExploreImageGallery.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnExploreImageGallery.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnExploreImageGalleryActionPerformed(evt);
            }
        });
        jToolBar1.add(btnExploreImageGallery);

        btnLogOut.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/exit64.png"))); // NOI18N
        btnLogOut.setToolTipText("Log Out");
        btnLogOut.setFocusable(false);
        btnLogOut.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnLogOut.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnLogOut.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLogOutActionPerformed(evt);
            }
        });
        jToolBar1.add(btnLogOut);
        jToolBar1.add(jSeparator1);

        jLabel9.setText("     ");
        jToolBar1.add(jLabel9);

        jLabel1.setText("Test: ");
        jToolBar1.add(jLabel1);

        lblTestName.setFont(new java.awt.Font("Lucida Grande", 1, 14)); // NOI18N
        lblTestName.setText("-");
        jToolBar1.add(lblTestName);

        jLabel8.setText("         ");
        jToolBar1.add(jLabel8);

        jLabel3.setText("Author: ");
        jToolBar1.add(jLabel3);

        lblAuthor.setFont(new java.awt.Font("Lucida Grande", 1, 14)); // NOI18N
        lblAuthor.setText("-");
        jToolBar1.add(lblAuthor);

        jLabel11.setText("         ");
        jToolBar1.add(jLabel11);

        btnEditTest.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/pencil24.png"))); // NOI18N
        btnEditTest.setText("Edit Info");
        btnEditTest.setEnabled(false);
        btnEditTest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditTestActionPerformed(evt);
            }
        });
        jToolBar1.add(btnEditTest);

        getContentPane().add(jToolBar1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 847, 80));

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Section", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Lucida Grande", 1, 13))); // NOI18N

        cmbSections.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cmbSectionsItemStateChanged(evt);
            }
        });

        btnEditSection.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/pencil24.png"))); // NOI18N
        btnEditSection.setText("Edit");
        btnEditSection.setEnabled(false);
        btnEditSection.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditSectionActionPerformed(evt);
            }
        });

        btnDeleteSection.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/delete24.png"))); // NOI18N
        btnDeleteSection.setText("Delete");
        btnDeleteSection.setEnabled(false);
        btnDeleteSection.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteSectionActionPerformed(evt);
            }
        });

        btnAddSection.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/add24.png"))); // NOI18N
        btnAddSection.setText("Add");
        btnAddSection.setEnabled(false);
        btnAddSection.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddSectionActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(cmbSections, 0, 174, Short.MAX_VALUE)
                    .add(jPanel1Layout.createSequentialGroup()
                        .add(43, 43, 43)
                        .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(btnDeleteSection, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 102, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(btnEditSection, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 104, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(btnAddSection, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 102, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(0, 39, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .add(cmbSections, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(btnEditSection)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(btnDeleteSection)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(btnAddSection)
                .addContainerGap(31, Short.MAX_VALUE))
        );

        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 120, 210, 220));

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "SubSection", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Lucida Grande", 1, 13))); // NOI18N

        cmbSubSections.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cmbSubSectionsItemStateChanged(evt);
            }
        });

        btnEditSubSection.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/pencil24.png"))); // NOI18N
        btnEditSubSection.setText("Edit");
        btnEditSubSection.setEnabled(false);
        btnEditSubSection.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditSubSectionActionPerformed(evt);
            }
        });

        btnDeleteSubSection.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/delete24.png"))); // NOI18N
        btnDeleteSubSection.setText("Delete");
        btnDeleteSubSection.setEnabled(false);
        btnDeleteSubSection.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteSubSectionActionPerformed(evt);
            }
        });

        btnAddSubSection.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/add24.png"))); // NOI18N
        btnAddSubSection.setText("Add");
        btnAddSubSection.setEnabled(false);
        btnAddSubSection.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddSubSectionActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(cmbSubSections, 0, 174, Short.MAX_VALUE))
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(50, 50, 50)
                        .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(btnEditSubSection, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 104, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(btnDeleteSubSection, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 104, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(btnAddSubSection, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 105, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .add(0, 37, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(cmbSubSections, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(btnEditSubSection)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(btnDeleteSubSection)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(btnAddSubSection)
                .addContainerGap(27, Short.MAX_VALUE))
        );

        getContentPane().add(jPanel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 350, 210, 210));

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Question", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Lucida Grande", 1, 13))); // NOI18N

        lstQuestions.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                lstQuestionsValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(lstQuestions);

        btnEditQuestion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/editView24.png"))); // NOI18N
        btnEditQuestion.setText("View/Edit");
        btnEditQuestion.setEnabled(false);
        btnEditQuestion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEditQuestionActionPerformed(evt);
            }
        });

        btnDeleteQuestion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/pencil24.png"))); // NOI18N
        btnDeleteQuestion.setText("Delete");
        btnDeleteQuestion.setEnabled(false);
        btnDeleteQuestion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteQuestionActionPerformed(evt);
            }
        });

        btnAddQuestion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/add24.png"))); // NOI18N
        btnAddQuestion.setText("Add");
        btnAddQuestion.setEnabled(false);
        btnAddQuestion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAddQuestionActionPerformed(evt);
            }
        });

        jLabel5.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N
        jLabel5.setText("Section:");

        lblSection.setFont(new java.awt.Font("Lucida Grande", 1, 18)); // NOI18N
        lblSection.setText("-");

        jLabel7.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N
        jLabel7.setText("Sub Section:");

        lblSubSection.setFont(new java.awt.Font("Lucida Grande", 1, 18)); // NOI18N
        lblSubSection.setText("-");

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3Layout.createSequentialGroup()
                        .add(btnEditQuestion, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 116, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                        .add(btnDeleteQuestion)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(btnAddQuestion)
                        .add(19, 19, 19))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3Layout.createSequentialGroup()
                        .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 624, Short.MAX_VALUE)
                        .addContainerGap())
                    .add(jPanel3Layout.createSequentialGroup()
                        .add(jLabel5)
                        .add(18, 18, 18)
                        .add(lblSection)
                        .add(110, 110, 110)
                        .add(jLabel7)
                        .add(18, 18, 18)
                        .add(lblSubSection)
                        .add(0, 361, Short.MAX_VALUE))))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(jLabel5)
                    .add(lblSection)
                    .add(jLabel7)
                    .add(lblSubSection))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 328, Short.MAX_VALUE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(btnDeleteQuestion)
                    .add(btnAddQuestion)
                    .add(btnEditQuestion))
                .addContainerGap())
        );

        getContentPane().add(jPanel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 120, 660, 440));

        btnTakeTest.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/takeTest48.png"))); // NOI18N
        btnTakeTest.setText("Preview");
        btnTakeTest.setEnabled(false);
        btnTakeTest.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
        btnTakeTest.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnTakeTestActionPerformed(evt);
            }
        });
        getContentPane().add(btnTakeTest, new org.netbeans.lib.awtextra.AbsoluteConstraints(760, 570, 130, 60));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnNewTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewTestActionPerformed
        dlgTestDetails.setVisible(true);
    }//GEN-LAST:event_btnNewTestActionPerformed

    private void btnOpenTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOpenTestActionPerformed

        //open the file chooser in a predifined directory
        JFileChooser file = new JFileChooser(new File(System.getProperty("user.dir")+"/src/savedTestFiles/"));
        file.setFileSelectionMode(JFileChooser.FILES_ONLY);
        file.setMultiSelectionEnabled(false);

        // Show the dialog; wait until dialog is closed
        int result = file.showOpenDialog(this);

        // Determine which button was clicked to close the dialog
        switch (result) {
            case JFileChooser.APPROVE_OPTION:
            // Approve (Open or Save) was clicked
                File filepath = file.getSelectedFile();
                controller.openTest(filepath.toString());
                 break;
            case JFileChooser.CANCEL_OPTION:
             // Cancel or the close-dialog icon was clicked
               System.out.println("as");
                 break;
            case JFileChooser.ERROR_OPTION:
             // The selection process did not complete successfully
                 break;
    }//GEN-LAST:event_btnOpenTestActionPerformed
    }

    private void btnSaveTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveTestActionPerformed
        controller.saveTest();
    }//GEN-LAST:event_btnSaveTestActionPerformed

    private void btnLogOutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLogOutActionPerformed

        //Exit this classGUI, asking the user if he is sure he wants to exit
        if (Utilities.messageOptionDialog("Any unsaved changes to the actual Test file will be lost. \n \n Do you want to continue?", this,urlQuestion)){
        
            MainGUI main = new MainGUI();
            main.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
            main.setVisible(true);
            this.dispose();
        } 
    }//GEN-LAST:event_btnLogOutActionPerformed

    private void btnEditSectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditSectionActionPerformed
        
          //open edit section DLG only if there is a section selected
          if (cmbSections.getSelectedIndex()>=0){
            newSection = false;                    //set flag variable to false because we are editing a existing question
            controller.fillAddEditSectionDLG();    //call this method which fills in information of the actual question in the dialog
            dlgAddEditSection.setVisible(true);
            lblModeSection.setText("You are currently EDITING an existing Section !");
        }
        else{
              Utilities.messageDialogWarning("No Section selected !", this,urlStop);
        }
    }//GEN-LAST:event_btnEditSectionActionPerformed

    private void btnDeleteSectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteSectionActionPerformed
        
        //delete the selected section in the combobox
        
        if (cmbSections.getSelectedIndex()>=0){
            controller.deleteSection();
        }
        else{
            Utilities.messageDialogWarning("No Section selected !", this,urlStop);
        }
    }//GEN-LAST:event_btnDeleteSectionActionPerformed

    private void btnAddSectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddSectionActionPerformed

        //shows the DLG to fill in info for a new section
        newSection = true;                  //set true because its a new ection
        dlgAddEditSection.setVisible(true);
        txtSectionName.setText("");
        txtSectionDescription.setText("");
        lblModeSection.setText("You are currently ADDING a new section!"); 
    }//GEN-LAST:event_btnAddSectionActionPerformed

    private void btnEditSubSectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditSubSectionActionPerformed
         
        //show the DLG for editing a subsection, only if there is a subsection selected
        if (cmbSubSections.getSelectedIndex()>=0){
            newSubSection = false;                    //set flag variable to false because we are editing a existing question
            controller.fillAddEditSubSectionDLG();    //call this method which fills in information of the actual question in the dialog
            dlgAddEditSubSection.setVisible(true);
            lblModeSubSection.setText("You are currently EDITING an existing SubSection !");
        }
         else{
             Utilities.messageDialogWarning("No SubSection selected !", this,urlStop);
         }
    }//GEN-LAST:event_btnEditSubSectionActionPerformed

    private void btnDeleteSubSectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteSubSectionActionPerformed
        
        //delete the selected subsection
        if (cmbSubSections.getSelectedIndex()>=0){
        controller.deleteSubSection();
        }
        else{
            Utilities.messageDialogWarning("No SubSection selected !", this,urlStop);
        }
    }//GEN-LAST:event_btnDeleteSubSectionActionPerformed

    private void btnAddSubSectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddSubSectionActionPerformed
        
        //show the DLG to fill in information for a new subsection, but only if there is a Section selected (to which it will be added)
        if (cmbSections.getSelectedIndex()>=0){ //only add a SubSection if a Section is selected
            newSubSection = true;               //set to true because its a new subsection
            dlgAddEditSubSection.setVisible(true);
            txtSubSectionName.setText("");
            txtSubSectionDescription.setText("");
            lblModeSubSection.setText("You are currently ADDING a new subsection!");
        }
        else{
            Utilities.messageDialogWarning("No selected Section !", this,urlStop);
        }
    }//GEN-LAST:event_btnAddSubSectionActionPerformed

    private void btnEditQuestionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditQuestionActionPerformed
        
        //show DLG for editing a question, only if there is a question selected
        if (lstQuestions.getSelectedIndex()>=0){
            newQuestion = false;                    //set flag variable to false because we are editing a existing question
            controller.fillAddEditQuestionDLG();    //call this method which fills in information of the actual question in the dialog
            dlgAddEditQuestion.setVisible(true);
            lblMode.setText("You are currently EDITING an existing question !");

            if (tabAddEditQuestion.getSelectedIndex() == 0) {
                //for use in MCQ
                modelList = (DefaultListModel) lstPossAnswers.getModel();             //update models that will be used to add and remove elements that was just filled in by the controller with info of the existing question
                modelComboBox = (DefaultComboBoxModel) cmbCorrectAnswer.getModel();   //update models that will be used to add and remove elements
            } else {
                if (!chbMultipleBlanks.isSelected()) {
                    //for use in FIBQ
                    modelListFIBQ = (DefaultListModel) lstCorrFIB.getModel();             //update the model from the list box in order to add and remove elements
                }
            }
        }
        else{
            Utilities.messageDialogWarning("No Question selected !", this,urlStop); 
        }   
    }//GEN-LAST:event_btnEditQuestionActionPerformed

    private void btnDeleteQuestionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteQuestionActionPerformed
       
       //delete the selected question
       if (lstQuestions.getSelectedIndex()>=0){
        controller.deleteQuestion();
       }
       else{
           Utilities.messageDialogWarning("No Question selected !", this,urlStop);
       }
    }//GEN-LAST:event_btnDeleteQuestionActionPerformed

    private void btnAddQuestionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddQuestionActionPerformed

        //show DLG for adding a new question, only if a subsection is selected (to which it will be added)
        if (cmbSubSections.getSelectedIndex()>=0){
            blankCounter=0;                                 //counter for amount of blanks (for FIBQ functions)
            newQuestion = true;                             //set True because its a new question
            dlgAddEditQuestion.setVisible(true);            
            tabAddEditQuestion.setEnabledAt(0, true);       //enable both tabs to allow user to add any type of question
            tabAddEditQuestion.setEnabledAt(1, true);
            lblMode.setText("You are currently ADDING a new question !");
        }
        else{
           Utilities.messageDialogWarning("No SubSection selected !", this,urlStop); 
        }  
    }//GEN-LAST:event_btnAddQuestionActionPerformed

    private void cmbSectionsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cmbSectionsItemStateChanged
        controller.sectionChanged(cmbSections.getSelectedIndex());
    }//GEN-LAST:event_cmbSectionsItemStateChanged

    private void cmbSubSectionsItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cmbSubSectionsItemStateChanged
        controller.subSectionChanged(cmbSubSections.getSelectedIndex());
    }//GEN-LAST:event_cmbSubSectionsItemStateChanged

    private void lstQuestionsValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_lstQuestionsValueChanged
        controller.questionChanged(lstQuestions.getSelectedIndex());
        
    }//GEN-LAST:event_lstQuestionsValueChanged

    private void btnCreateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCreateActionPerformed
                
        //Create a new Test afetr user enter data in DLG
        //Validate all the fields
        
        //steps to validate characters, creates the array of fields and send it to the validating method
        ArrayList<String> fields = new ArrayList<String>();
        fields.add(txtTestName.getText());
        fields.add(txtAuthor.getText());
        fields.add(txtDescription.getText());
        String temp = Utilities.checkEspCharacters(fields);
        //
        if (txtTestName.getText().equals("")){//name cannot be empty
            dlgTestDetails.toFront();
            //JOptionPane.showMessageDialog(this,"Invalid Information");
            Utilities.messageDialogWarning("Please give the Test a name",this.dlgTestDetails,urlStop);
        }
        else if(!temp.equals("")){//check if any reserved characters are beeing used
            Utilities.messageDialogWarning("The following characters are not allowed: \n \n"+temp, this.dlgTestDetails,urlStop);
        }
        else
        {
            controller.createTest(txtTestName.getText(),txtAuthor.getText(),txtDescription.getText());
            dlgTestDetails.setVisible(false);
            Utilities.messageDialogOK("Test created", this,urlDone);
            txtTestName.setText("");
            txtAuthor.setText("");
            txtDescription.setText("");
        }
    }//GEN-LAST:event_btnCreateActionPerformed

    private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed

        //user hits cancel button, clear all fields and set visibility to false of the DLG
        txtTestName.setText("");
        txtAuthor.setText("");
        txtDescription.setText("");
        dlgTestDetails.setVisible(false);
    }//GEN-LAST:event_btnCancelActionPerformed

    private void btnTakeTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnTakeTestActionPerformed
        
        //method called when the user wants to preview the test he is creating
        
        //OPTION 1
        //THIS IS FOR SAVING THE TEST BEFORE PREVIEW (verify test is considered complete)
        
        /*
        if (messageOptionDialog("Previewing the test will automatically save the test. \n \n Do you want to continue?", this)){//
       
            if (controller.saveTest()){//saveTest() saves the test if its complete and returns true
                StudentGUI student = new StudentGUI();
                StudentController studentController = new StudentController(student,lblTestName.getText(),false,null);
                student.setVisible(true);
            }
        }
        */
        
        //OPTION 2
        //THIS IS FOR PREVIEWING THE TEST DIRECTLY PASSING THE OBJECT (verify test is not empty)
        if (!controller.getTest().getSections().isEmpty()){ //check that the test is not completely empty
        
            StudentGUI student = new StudentGUI();                                                              //create a new StudentGUI object
            StudentController studentController = new StudentController(student,controller.getTest(),false,cmbSections.getSelectedIndex());    //create a new controller for the GUI, setting the variable isStudent to false (can navigate back and forth, and timmer disabled)
            student.setVisible(true);
        }
        else{
            Utilities.messageDialogWarning("The actual Test is empty", this,urlStop);
        }
     
    }//GEN-LAST:event_btnTakeTestActionPerformed

    private void btnCancelAddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelAddActionPerformed

        //close DLG and clear fields
        this.cleanQuestionForm();
    }//GEN-LAST:event_btnCancelAddActionPerformed

    private void btnSelectImageMCQActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSelectImageMCQActionPerformed

        ImageLibraryGUI imageLib = new ImageLibraryGUI(this, "MCQ");
        imageLib.setVisible(true);  
    }//GEN-LAST:event_btnSelectImageMCQActionPerformed

    private void btnDeletePossActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeletePossActionPerformed
        
        //delete from the list the selected possible answer of MCQ
        int i=lstPossAnswers.getSelectedIndex();

        if (lstPossAnswers.getSelectedIndex() != -1){
            modelList.remove(i);
            cmbCorrectAnswer.removeItemAt(i);
            
            this.updatePenaltyMCQ();
        }
    }//GEN-LAST:event_btnDeletePossActionPerformed

    
    private void btnSaveQuestionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveQuestionActionPerformed
       
        //save the question information entered by the user (MCQ or FIQ)
        //type of question detected by the selected tab

         if (tabAddEditQuestion.getSelectedIndex() == 0) {
        //////////////
        //FOR MCQ
        ///////////
            this.saveQuestionMCQ();
        }
        else if(tabAddEditQuestion.getSelectedIndex() == 1){
        //////////////////////////////////
        //FOR FIBQ (single or multiple) //
        //////////////////////////////////  
            this.saveQuestionBLANK();
        } 
    }//GEN-LAST:event_btnSaveQuestionActionPerformed

  
    private void txtMarksActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtMarksActionPerformed

        this.updatePenaltyMCQ();
    }//GEN-LAST:event_txtMarksActionPerformed

    private void btnSaveSubSectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveSubSectionActionPerformed
        
        //save subsection information eneterd by user
        
        //steps to validate characters
        ArrayList<String> fields = new ArrayList<String>();
        fields.add(txtSubSectionName.getText());
        fields.add(txtSubSectionDescription.getText());
        String temp = Utilities.checkEspCharacters(fields);
        //
        if (!txtSubSectionName.getText().equals("") && !txtSubSectionDescription.getText().equals("")){//check for empty fields
            
            if(temp.equals("")){//check if any reserved charcters were detected
                controller.createEditSubSection(txtSubSectionName.getText(),txtSubSectionDescription.getText(),newSubSection); //create or edit the section
                dlgAddEditSubSection.setVisible(false);
                txtSubSectionName.setText("");
                txtSubSectionDescription.setText("");
            }
            else{
                Utilities.messageDialogWarning("The following character(s) are not allowed: \n \n"+temp, this.dlgTestDetails,urlStop);
            }
        }
        else{
            
            Utilities.messageDialogWarning("Please complete all the information!",this.dlgAddEditSubSection,urlStop);
        }  
    }//GEN-LAST:event_btnSaveSubSectionActionPerformed

    private void btnCancelSubSectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelSubSectionActionPerformed
        
        //hide the DLG and clear fields
        dlgAddEditSubSection.setVisible(false);
        txtSubSectionName.setText("");
        txtSubSectionDescription.setText("");
    }//GEN-LAST:event_btnCancelSubSectionActionPerformed

    private void btnCancelSectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelSectionActionPerformed
        
        //hide DLG and clear fields
        dlgAddEditSection.setVisible(false);
        txtSectionName.setText("");
        txtSectionDescription.setText("");
        txtSectionTime.setText("");
    }//GEN-LAST:event_btnCancelSectionActionPerformed

    private void btnSaveSectionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSaveSectionActionPerformed

        //steps to validate characters
        ArrayList<String> fields = new ArrayList<String>();
        fields.add(txtSectionName.getText());
        fields.add(txtSectionDescription.getText());
        fields.add(txtSectionTime.getText());
        String temp = Utilities.checkEspCharacters(fields);
        //
        if (!txtSectionName.getText().equals("") && !txtSectionDescription.getText().equals("") && !txtSectionTime.getText().equals("")){//check for empty fields
            if(temp.equals("")){//means no characters detected
                if(Utilities.isPositiveInteger(txtSectionTime.getText())){
                    
                    //create or edit the section with data eneterd by user
                    controller.createEditSection(txtSectionName.getText(),txtSectionDescription.getText(),Integer.parseInt(txtSectionTime.getText()),newSection);
                    dlgAddEditSection.setVisible(false);
                    txtSectionName.setText("");
                    txtSectionDescription.setText("");
                    txtSectionTime.setText("");    
                }
                else{
                    Utilities.messageDialogWarning("Please insert a valid time limit", this.dlgTestDetails,urlStop);
                }   
            }
            else{
                Utilities.messageDialogWarning("The following character(s) are not allowed: \n \n"+temp, this.dlgTestDetails,urlStop);
            }  
        }
        else{
            Utilities.messageDialogWarning("Please complete all the information!",this.dlgAddEditSection,urlStop);
        } 
    }//GEN-LAST:event_btnSaveSectionActionPerformed

    private void btnEditTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditTestActionPerformed
        
        //opens DLG and calls controller method that fills in actual info
        controller.fillEditTestDLG();
        dlgEditTest.setVisible(true);
    }//GEN-LAST:event_btnEditTestActionPerformed

    private void btnCancelEditTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelEditTestActionPerformed
        
        //hide DLG and clear fields
        dlgEditTest.setVisible(false);
        txtEditTestName.setText("");
        txtEditAuthor.setText("");
        txtEditTestDesc.setText("");
    }//GEN-LAST:event_btnCancelEditTestActionPerformed

    private void btnConfirmEditTestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnConfirmEditTestActionPerformed
                
        //steps to validate characters
        ArrayList<String> fields = new ArrayList<String>();
        fields.add(txtEditTestName.getText());
        fields.add(txtEditAuthor.getText());
        fields.add(txtEditTestDesc.getText());
        String temp = Utilities.checkEspCharacters(fields);
        
        if(txtEditTestName.getText().equals("")){
            Utilities.messageDialogWarning("Please give the Test a name",this.dlgEditTest,urlStop);
        }
        else if(!temp.equals("")){
            Utilities.messageDialogWarning("The following characters are not allowed: \n \n"+temp, this.dlgEditTest,urlStop);
        }
        else
        {
            
            controller.editTest(txtEditTestName.getText(), txtEditAuthor.getText(),txtEditTestDesc.getText());
            dlgEditTest.setVisible(false);
        }
    }//GEN-LAST:event_btnConfirmEditTestActionPerformed

    
    private void btnAddTextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddTextActionPerformed
       
        final JTextField txtTemp = new JTextField();
        txtTemp.setPreferredSize(new Dimension(200,23));
        txtTemp.setText("Insert Text here");
        pnlQuestion.add(txtTemp);
        pnlQuestion.revalidate();
        
         txtTemp.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                if (txtTemp.getText().equals("Insert Text here")) {
                    txtTemp.setText("");
                }
            }
        });
    }//GEN-LAST:event_btnAddTextActionPerformed

    private void btnAddBlankActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddBlankActionPerformed
        // TODO add your handling code here:

        if (chbMultipleBlanks.isSelected() || (!chbMultipleBlanks.isSelected() && blankCounter == 0)) {
            blankCounter++;
            JLabel lblTemp = new JLabel();
            lblTemp.setText("_______");
            pnlQuestion.add(lblTemp);
            pnlQuestion.revalidate();

            if (!chbMultipleBlanks.isSelected()) {
                btnAddBlank.setEnabled(false);      //disable button to add blanks if Multiple blanks is not enabled
            }
        }
        
        //dont allow user to add blanks (in multiple blank enabled) and the go back to unselect multiple blank
        if(blankCounter>1){
            chbMultipleBlanks.setEnabled(false);
        }

    }//GEN-LAST:event_btnAddBlankActionPerformed

    private void btnAddCorrFIBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddCorrFIBActionPerformed
        // TODO add your handling code here:
        //add Possible answer to MCQ question in DLG
        
        //send user input to check for reserved characters
        String temp = Utilities.checkEspCharacters(txtCorrAnswerFIB.getText());
        
            if (!txtCorrAnswerFIB.getText().equals("")) {//dont allow empty options
                if (temp.equals("")) {//check if any reserved characters where deteted / empty means no especial characters detected
                    
                    //check with the already exisiting options o validated the option is not repeated
                    Boolean tempFlag=true;
                    
                    for (int i=0;i<lstCorrFIB.getModel().getSize();i++){
                        if(lstCorrFIB.getModel().getElementAt(i).equals(txtCorrAnswerFIB.getText())){
                            tempFlag=false; //option already exists
                        }
                    }
                    
                    if (tempFlag){
                        modelListFIBQ.addElement(txtCorrAnswerFIB.getText());
                        lstCorrFIB.setModel(modelListFIBQ);
                        txtCorrAnswerFIB.setText("");
                        txtCorrAnswerFIB.grabFocus();
                    }
                    else{
                        Utilities.messageDialogWarning("That option already exists!", dlgAddEditQuestion,urlStop);
                    }
                } 
                else {
                    Utilities.messageDialogWarning("The following characters are not allowed: \n \n" + temp, this.dlgAddEditQuestion,urlStop);
                }
            } 
            else {
                Utilities.messageDialogWarning("Empty option", this.dlgAddEditQuestion,urlStop);
            }
    }//GEN-LAST:event_btnAddCorrFIBActionPerformed

    private void btnDeleteCorrFIBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteCorrFIBActionPerformed
        // TODO add your handling code here:
          //delete from the list the selected possible answer of MCQ
        int i=lstCorrFIB.getSelectedIndex();

        if (lstCorrFIB.getSelectedIndex() != -1)
            modelListFIBQ.remove(i);
    }//GEN-LAST:event_btnDeleteCorrFIBActionPerformed

    private void btnClearQuestionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnClearQuestionActionPerformed
        // TODO add your handling code here:
        pnlQuestion.removeAll();
        pnlQuestion.repaint();
        btnAddBlank.setEnabled(true);
        btnAddText.setEnabled(true);
        blankCounter=0;
        //do not enable checkbox if you are editing a question, you cannot change the type of question
        if(newQuestion){
            chbMultipleBlanks.setEnabled(true);
        }
    }//GEN-LAST:event_btnClearQuestionActionPerformed

    private void chbMultipleBlanksItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chbMultipleBlanksItemStateChanged
        // TODO add your handling code here:
        if (chbMultipleBlanks.isSelected()){
            txtCorrAnswerFIB.setEnabled(false);
            btnAddCorrFIB.setEnabled(false);
            btnDeleteCorrFIB.setEnabled(false);
            lstCorrFIB.setEnabled(false);
            lstCorrFIB.setBackground(new Color(222,225,229));
            btnAddBlank.setEnabled(true);
        }
        else{
            txtCorrAnswerFIB.setEnabled(true);
            btnAddCorrFIB.setEnabled(true);
            btnDeleteCorrFIB.setEnabled(true);
            lstCorrFIB.setEnabled(true);
            lstCorrFIB.setBackground(Color.white);
            
            //disable button to add blanks if there is already a blank in the question
            if(blankCounter>0){
                btnAddBlank.setEnabled(false);
            }
            
        }      
    }//GEN-LAST:event_chbMultipleBlanksItemStateChanged

    private void txtPenaltyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtPenaltyActionPerformed
        // TODO add your handling code here:
   
    }//GEN-LAST:event_txtPenaltyActionPerformed

    private void chbAutoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chbAutoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_chbAutoActionPerformed

    private void chbMultipleBlanksActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_chbMultipleBlanksActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_chbMultipleBlanksActionPerformed

    private void chbAutoItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_chbAutoItemStateChanged
        
        this.updatePenaltyMCQ();
        
        if(chbAuto.isSelected()){
            txtPenalty.setEnabled(false);
        }
        else{
            txtPenalty.setEnabled(true);
        }
    }//GEN-LAST:event_chbAutoItemStateChanged

    private void txtMarksFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_txtMarksFocusLost
        this.updatePenaltyMCQ();
    }//GEN-LAST:event_txtMarksFocusLost

    private void btnAddPoss1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAddPoss1ActionPerformed
                
        //add Possible answer to MCQ question in DLG
        
        //send user input to check for reserved characters
        String temp = Utilities.checkEspCharacters(txtPossAnswer.getText());
        
        if(lstPossAnswers.getModel().getSize()<6){//maximum number of options is 6

            if (!txtPossAnswer.getText().equals("")) {//dont allow empty options
                if (temp.equals("")) {//check if any reserved characters where deteted / empty means no especial characters detected
                    
                    //check with the already exisiting options o validated the option is not repeated
                    Boolean tempFlag=true;
                    
                    for (int i=0;i<lstPossAnswers.getModel().getSize();i++){
                        if(lstPossAnswers.getModel().getElementAt(i).equals(txtPossAnswer.getText())){
                            tempFlag=false; //option already exists
                        }
                    }
                    
                    if (tempFlag){
                        modelList.addElement(txtPossAnswer.getText());
                        lstPossAnswers.setModel(modelList);
                        cmbCorrectAnswer.addItem(txtPossAnswer.getText());
                        txtPossAnswer.setText("");
                        txtPossAnswer.grabFocus();
                        
                        this.updatePenaltyMCQ();
                    }
                    else{
                        Utilities.messageDialogWarning("That option already exists!", dlgAddEditQuestion,urlStop);
                    }
                } 
                else {
                    Utilities.messageDialogWarning("The following characters are not allowed: \n \n" + temp, this.dlgAddEditQuestion,urlStop);
                }
            } 
            else {
                Utilities.messageDialogWarning("Empty option", this.dlgAddEditQuestion,urlStop);
            }
        }
        else{
            Utilities.messageDialogWarning("You have reached the maximun number of possible answers (6) !", this.dlgAddEditQuestion,urlStop);
        }
    }//GEN-LAST:event_btnAddPoss1ActionPerformed

    private void btnSelectImageMCQ1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSelectImageMCQ1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_btnSelectImageMCQ1ActionPerformed

    private void btnRemoveImageMCQActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveImageMCQActionPerformed
        lblImageMCQ.setText("No image");
    }//GEN-LAST:event_btnRemoveImageMCQActionPerformed

    private void btnSelectImageBLANKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnSelectImageBLANKActionPerformed
        ImageLibraryGUI imageLib = new ImageLibraryGUI(this, "BLANK");
        imageLib.setVisible(true);
    }//GEN-LAST:event_btnSelectImageBLANKActionPerformed

    private void btnRemoveImageBLANKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRemoveImageBLANKActionPerformed

        lblImageBLANK.setText("No image");
    }//GEN-LAST:event_btnRemoveImageBLANKActionPerformed

    private void btnExploreImageGalleryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnExploreImageGalleryActionPerformed
        // TODO add your handling code here:
        ImageLibraryGUI imageLib = new ImageLibraryGUI(null, "EXPLORER");
        imageLib.setVisible(true);
    }//GEN-LAST:event_btnExploreImageGalleryActionPerformed

    
    //method for updating the penalty for MCQ
    private void updatePenaltyMCQ() {

        if (chbAuto.isSelected() && (lstPossAnswers.getModel().getSize() > 1) && Utilities.isPositiveInteger(txtMarks.getText())) {
        // the auto is selected AND the size of the list is greater than one (at least one wrong option) and the marks is a valid number
            float a;
            float b;
            float r;
            String s;

            a = Float.parseFloat(txtMarks.getText());
            b = lstPossAnswers.getModel().getSize();
            r = a / (b - 1);

            txtPenalty.setText(String.valueOf(r));

            txtPenalty.setText(String.format("%.2f", r));

        } else if (chbAuto.isSelected() && ((lstPossAnswers.getModel().getSize() <= 1) || !Utilities.isPositiveInteger(txtMarks.getText()))){
        //the auto is selected AND (the list has no wrong options or the marks are not a valid number)
            txtPenalty.setText("0.0");
        } 
    }

    
    //method for cleaning the ADD/EDIT question form
    private void cleanQuestionForm(){
        modelList.removeAllElements();
        lstPossAnswers.setModel(modelList);
        cmbCorrectAnswer.removeAllItems();
        txtQuestion.setText("");
        txtMarks.setText("");
        txtPenalty.setText("0");
        txtPossAnswer.setText("");
        chbAuto.setSelected(false);
        txtPenalty.setEnabled(true);
        
        modelListFIBQ.removeAllElements();
        lstPossAnswers.setModel(modelListFIBQ);
        txtMarksFIB.setText("");
        txtPenaltyFIB.setText("0");
        txtCorrAnswerFIB.setText("");
        chbMultipleBlanks.setEnabled(true);
        chbMultipleBlanks.setSelected(false);
        pnlQuestion.removeAll();
        pnlQuestion.repaint();
        btnAddBlank.setEnabled(true);
        btnAddText.setEnabled(true);

        dlgAddEditQuestion.setVisible(false);
        
        lblImageMCQ.setText("No image");
        lblImageBLANK.setText("No image");
    }
    
    
    
    
    //method to create/save a MCQ question. validates all inputs and if it succeeds then call the controller. This method is called by the listener ob the save button depending on the selected tab
    private void saveQuestionMCQ() {

        ArrayList<String> PossAns = new ArrayList<String>();                    //(MCQ) arrayList containing the possible answers
        
        //check for any reserved characters (the other fields have already been validated)
        String temp = Utilities.checkEspCharacters(txtQuestion.getText());

        if ((!txtQuestion.getText().equals("")) && !txtMarks.getText().equals("") && !txtPenalty.getText().equals("") && (lstPossAnswers.getModel().getSize() > 1)) {//check for empty fields

            if (Utilities.isPositiveInteger(txtMarks.getText()) && Utilities.isPositiveFloat(txtPenalty.getText())) {//validate that the number of marks is a valid intiger

                if (temp.equals("")) {

                    //copy data from the list into the array
                    for (int i = 0; i < modelList.getSize(); i++) {
                        PossAns.add(modelList.getElementAt(i).toString());
                    }

                    //call the controller to create or edit the question and clear fields
                    controller.createEditQuestionMCQ(txtQuestion.getText(), Integer.parseInt(txtMarks.getText()), Float.parseFloat(txtPenalty.getText()), PossAns, cmbCorrectAnswer.getSelectedIndex(),lblImageMCQ.getText(), newQuestion);
                    this.cleanQuestionForm();
                } else {
                    Utilities.messageDialogWarning("The following character(s) are not allowed: \n \n" + temp, this.dlgTestDetails, urlStop);
                }
            } else {
                Utilities.messageDialogWarning("Please enter a valid number of marks/penalty", this.dlgAddEditQuestion, urlStop);
            }

        } else {
            Utilities.messageDialogWarning("Please complete all the information!", this.dlgAddEditQuestion, urlStop);
        }
    }
    
    
    
    
    //method to create/save a FILL BLANK question. validates all inputs and if it succeeds then call the controller. This method is called by the listener ob the save button depending on the selected tab
    //if validation succeeds, then the appropiate method is called depending on Single of Multiple
    private void saveQuestionBLANK(){

            ArrayList<String> CorrAns = new ArrayList<String>();                    //(FIBQ)arrayList containing the correct answers
        
            //create the question text looping through all elements in the panel
            //and count the number of txt and blanks
            String tempQuestion="";
            boolean flagTxtBoxes=false; //flag that goes true if txtboxes are empty or have "Insert Text here"
            int Numblanks=0; //for validation
            int Numtxts=0;        
            for(Component tempComp:pnlQuestion.getComponents()){
                
                if (tempComp instanceof JTextField){
                    String tempCheck=""; //variable for checking empty textboxes
                    tempCheck=((JTextField)tempComp).getText();
                    tempCheck=Utilities.replace(tempCheck, "<blank>", "BLANK");      //remove "<blank>" if entered by the user by mistake
                    tempQuestion+=tempCheck;                        
                    
                    if(tempCheck.equals("") || tempCheck.equals("Insert Text here")){
                        flagTxtBoxes=true;
                    }
                    Numtxts++;
                }
                else if (tempComp instanceof JLabel){
                    tempQuestion+="<blank>";
                    Numblanks++;
                }
            }
            
            String temp = Utilities.checkEspCharacters(tempQuestion);
            
            
            if (!flagTxtBoxes){
         
                if (!tempQuestion.equals("") && !txtMarksFIB.getText().equals("")&& !txtPenaltyFIB.getText().equals("")){

                    if(Utilities.isPositiveInteger(txtMarksFIB.getText()) && Utilities.isPositiveFloat(txtPenaltyFIB.getText())){

                        if (temp.equals("")){

                            if(!chbMultipleBlanks.isSelected()){
                                /////////////////////
                                // FOR SINGLE BLANKS
                                ////////////////////
                                if(lstCorrFIB.getModel().getSize()!=0){
                                    
                                    if (Numblanks>0 && Numtxts>0){ //at least one blank and one txt

                                        for (int i = 0; i < modelListFIBQ.getSize(); i++) {
                                            CorrAns.add(modelListFIBQ.getElementAt(i).toString());
                                        }

                                        //call the controller to create or edit the question and clear fields
                                        controller.createEditQuestionFIBQ(tempQuestion, Integer.parseInt(txtMarksFIB.getText()),Float.parseFloat(txtPenaltyFIB.getText()), CorrAns, lblImageBLANK.getText(),newQuestion);
                                        this.cleanQuestionForm();
                                    }
                                    else{
                                        Utilities.messageDialogWarning("Question must have at least one text and one blank!", dlgAddEditQuestion,urlStop);
                                    }
                                }
                                else{
                                    Utilities.messageDialogWarning("Please add at least one correct answer!", dlgAddEditQuestion,urlStop);
                                }
                            }
                            else{
                                //////
                                //  FOR MULTIPLE BLANKS
                                //////
                                if (Numblanks>1 && Numtxts>0){
                                    
                                    //call the controller to create or edit the question and clear fields
                                        controller.createEditQuestionMFIBQ(tempQuestion, Integer.parseInt(txtMarksFIB.getText()),Float.parseFloat(txtPenaltyFIB.getText()), lblImageBLANK.getText(),newQuestion);
                                        this.cleanQuestionForm();                  

                                }
                                else{
                                    Utilities.messageDialogWarning("Question must have at least TWO blanks!", dlgAddEditQuestion,urlStop);
                                }    
                            }
                        }

                        else{
                            Utilities.messageDialogWarning("The following character(s) are not allowed: \n \n"+temp, this.dlgTestDetails,urlStop);
                        }
                    }
                    else{
                        Utilities.messageDialogWarning("Please enter a valid number of marks / penalty",this.dlgAddEditQuestion,urlStop);
                    }
                }
                else{
                    Utilities.messageDialogWarning("Please complete all the information!",this.dlgAddEditQuestion,urlStop);
                }
            }
            else{
                Utilities.messageDialogWarning("Please complete text of question",this.dlgAddEditQuestion,urlStop); 
            }
  }
    
    
    
    
    
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    public javax.swing.JButton btnAddBlank;
    private javax.swing.JButton btnAddCorrFIB;
    private javax.swing.JButton btnAddPoss1;
    public javax.swing.JButton btnAddQuestion;
    public javax.swing.JButton btnAddSection;
    public javax.swing.JButton btnAddSubSection;
    public javax.swing.JButton btnAddText;
    private javax.swing.JButton btnCancel;
    private javax.swing.JButton btnCancelAdd;
    private javax.swing.JButton btnCancelEditTest;
    private javax.swing.JButton btnCancelSection;
    private javax.swing.JButton btnCancelSubSection;
    private javax.swing.JButton btnClearQuestion;
    private javax.swing.JButton btnConfirmEditTest;
    private javax.swing.JButton btnCreate;
    private javax.swing.JButton btnDeleteCorrFIB;
    private javax.swing.JButton btnDeletePoss;
    public javax.swing.JButton btnDeleteQuestion;
    public javax.swing.JButton btnDeleteSection;
    public javax.swing.JButton btnDeleteSubSection;
    public javax.swing.JButton btnEditQuestion;
    public javax.swing.JButton btnEditSection;
    public javax.swing.JButton btnEditSubSection;
    public javax.swing.JButton btnEditTest;
    private javax.swing.JButton btnExploreImageGallery;
    private javax.swing.JButton btnLogOut;
    private javax.swing.JButton btnNewTest;
    private javax.swing.JButton btnOpenTest;
    private javax.swing.JButton btnRemoveImageBLANK;
    private javax.swing.JButton btnRemoveImageMCQ;
    private javax.swing.JButton btnSaveQuestion;
    private javax.swing.JButton btnSaveSection;
    private javax.swing.JButton btnSaveSubSection;
    private javax.swing.JButton btnSaveTest;
    private javax.swing.JButton btnSelectImageBLANK;
    private javax.swing.JButton btnSelectImageMCQ;
    private javax.swing.JButton btnSelectImageMCQ1;
    public javax.swing.JButton btnTakeTest;
    public javax.swing.JCheckBox chbAuto;
    public javax.swing.JCheckBox chbMultipleBlanks;
    public javax.swing.JComboBox cmbCorrectAnswer;
    public javax.swing.JComboBox cmbSections;
    public javax.swing.JComboBox cmbSubSections;
    private javax.swing.JDialog dlgAddEditQuestion;
    private javax.swing.JDialog dlgAddEditSection;
    private javax.swing.JDialog dlgAddEditSubSection;
    private javax.swing.JDialog dlgEditTest;
    private javax.swing.JDialog dlgTestDetails;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel35;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JLabel jLabel41;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JToolBar jToolBar1;
    public javax.swing.JLabel lblAuthor;
    public javax.swing.JLabel lblImageBLANK;
    public javax.swing.JLabel lblImageMCQ;
    public javax.swing.JLabel lblMode;
    private javax.swing.JLabel lblModeSection;
    private javax.swing.JLabel lblModeSubSection;
    public javax.swing.JLabel lblSection;
    public javax.swing.JLabel lblSubSection;
    public javax.swing.JLabel lblTestName;
    public javax.swing.JList lstCorrFIB;
    public javax.swing.JList lstPossAnswers;
    public javax.swing.JList lstQuestions;
    public javax.swing.JPanel pnlQuestion;
    public javax.swing.JTabbedPane tabAddEditQuestion;
    private javax.swing.JTextField txtAuthor;
    public javax.swing.JTextField txtCorrAnswerFIB;
    private javax.swing.JTextField txtDescription;
    public javax.swing.JTextField txtEditAuthor;
    public javax.swing.JTextField txtEditTestDesc;
    public javax.swing.JTextField txtEditTestName;
    public javax.swing.JTextField txtMarks;
    public javax.swing.JTextField txtMarksFIB;
    public javax.swing.JTextField txtPenalty;
    public javax.swing.JTextField txtPenaltyFIB;
    public javax.swing.JTextField txtPossAnswer;
    public javax.swing.JTextField txtQuestion;
    public javax.swing.JTextField txtSectionDescription;
    public javax.swing.JTextField txtSectionName;
    public javax.swing.JTextField txtSectionTime;
    public javax.swing.JTextField txtSubSectionDescription;
    public javax.swing.JTextField txtSubSectionName;
    private javax.swing.JTextField txtTestName;
    // End of variables declaration//GEN-END:variables
}




